package com.smart_campus.teg.controller;

import com.smart_campus.sys.common.DataGridView;
import com.smart_campus.sys.common.ResultObj;
import com.smart_campus.teg.common.TEGResultObj;
import com.smart_campus.teg.service.PersonnelService;
import com.smart_campus.teg.vo.StudentVo;
import com.smart_campus.teg.vo.TeacherVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @aytgor 陈鹏
 * @date 2020/6/20 9:04
 */

@RestController
@RequestMapping("personnel")
public class PersonnelController {

    @Autowired
    private PersonnelService personnelService;

    /**
     * 获取老师信息
     * @param teacherVo
     * @return
     */
    @RequestMapping("TeacherList")
    public DataGridView TeacherList(TeacherVo teacherVo){
        return personnelService.TeacherList(teacherVo);
    }

    /**
     * 获取老师的课程
     * @param userId
     * @return
     */
    @RequestMapping("getCourseTeacher")
    public DataGridView CourseTeacher(Integer userId){
        return personnelService.CourseTeacher(userId);
    }

    /**
     * 修改老师的课程
     * @param uid
     * @param Cids
     * @return
     */
    @RequestMapping("setCourseTeacher")
    public TEGResultObj setCourseTeacher(Integer uid,Integer[] Cids){
        try {
            this.personnelService.setCourseTeacher(uid, Cids);
            return TEGResultObj.TEACHER_YES;
        } catch (Exception e) {
            e.printStackTrace();
            return TEGResultObj.TEACHER_NO;
        }
    }

    /**
     * 查询全部学生
     * @param studentVo
     * @return DataGridView
     */
    @RequestMapping("StudentList")
    public DataGridView StudentList(StudentVo studentVo){
        return personnelService.StudentList(studentVo);
    }

    /**
     * 获取某个学生的班级
     * @param userId
     * @return
     */
    @RequestMapping("getStudentClass")
    public DataGridView getStudentClass(Integer userId){
        return personnelService.getStudentClass(userId);
    }

    @RequestMapping("setStudentClass")
    public TEGResultObj setStudentClass(Integer uid,Integer cid){
        try {
            this.personnelService.setStudentClass(uid,cid);
            return TEGResultObj.STUDENT_YES;
        } catch (Exception e) {
            e.printStackTrace();
            return TEGResultObj.STUDENT_NO;
        }
    }

}
